package com.mose;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * --
 */
@RestController
@RequestMapping
public class ConsumerController {

    @Resource
    private RestTemplate restTemplate;
    @Autowired
    private MyFeignClient myFeignClient;

    // 使用了router后, RestTemplate 会无法使用, 推荐使用FeignClient
    @GetMapping("r")
    public String consumer() {
        return restTemplate.getForObject("http://tencent-provider", String.class);
    }

    @GetMapping
    public String consumer2() {
        return myFeignClient.get();
    }

}
